const vaildJSON = json => {
  try {
    JSON.parse(json)
    return true
  } catch (e) {
    console.log(e);
    return false
  }
}

const json = '{"name":"imooc","course":"es"}'
console.log(vaildJSON(json));